import { serverUrl } from "./request";

/**
 * 处理图片地址
 * @param {*} url
 * @returns
 */
export const dalImg = (url) => {
  if (url) {
    if (url.startsWith("http")) {
      return url;
    }
    return serverUrl + url;
  }
  return "https://img2.baidu.com/it/u=1517799202,1136383175&fm=253&fmt=auto&app=138&f=JPEG?w=567&h=355";
};

/**
 * 设置
 * @param {*} token
 */
export const setToken = (token) => {
  sessionStorage.setItem("token", token);
};

/**
 * 获取
 * @returns
 */
export const getToken = () => sessionStorage.getItem("token");

/**
 * 删除
 * @returns
 */
export const removeToken = () => sessionStorage.removeItem("token");

/**
 * 是否登录
 */
export const isLogined = () => (getToken() ? true : false);
